package com.tude._07vehicle.base.interceptor;

import com.tude._07vehicle.pojo.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Slf4j
public class LoginCheckInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("进入登录校验的拦截器");
        UserVO userVO = (UserVO) request.getSession().getAttribute("user");
        if (userVO == null) {
            response.sendRedirect("/login.html");
            return false;
        }
        return true;
    }
}
